#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
void handle_sigcld(int signo)
{
    pid_t pid;
    int status;
    printf("current pid is %d\n", getpid());
    if((pid = wait(&status)) != -1)
    {
        printf("child process %dexit\n",pid);
    }
    if(WIFEXITED(status))
    {
        printf("child exit and return%d\n",WEXITSTATUS(status));
    }
    if(WIFSIGNALED(status))
    {
        printf("child process is killed by %d and end\n",WTERMSIG(status));
    }
}
main()
{
    pid_t pid;
    signal(SIGCLD,handle_sigcld);//SIGNCLD is the signal the child process sending when its stoped
    if((pid = fork()) < 0)
    {
        perror("fork");
        exit(0);
    }
    if(pid == 0)
    {
       printf(" child process pid %d\n", getpid() );
       exit(123);
    }
    printf("father process pid %d\n", getpid());
    sleep(5);
}